<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
    <link rel="stylesheet" href="weui.css"/>
    <link rel="stylesheet" href="example.css"/>
    <title>下单详情</title>
</head>
<body>
<script src="jquery.min.js"></script>
<div class="container">
    <div class="weui-panel weui-panel_access" >
        <div class="weui-panel__hd">收货地址</div>
        <div class="weui-panel__bd">
            <div class="weui-media-box weui-media-box_text">
                <h4 class="weui-media-box__title">张松松  13228713916</h4>
                <p class="weui-media-box__desc">河南省焦作市温县中心花园320号</p>
            </div>
        </div>
    </div>


    <div class="page__bd" >
        <div class="weui-panel weui-panel_access">
            <div class="weui-panel__hd">购买商品</div>
            <div class="weui-panel__bd">
                <a href="javascript:" class="weui-media-box weui-media-box_appmsg">
                    <div class="weui-media-box__hd">
                        <img class="weui-media-box__thumb" src="https://img14.360buyimg.com/n1/jfs/t1/118280/6/14900/107256/5f353518E8b08a0e9/77b119fcdf17a794.jpg" alt="">
                    </div>
                    <div class="weui-media-box__bd">
                        <h4 class="weui-media-box__title"><span style="color: #888888;float: right;">数量*1</span></h4>
                        <p class="weui-media-box__desc" ></p>
                        <h4 class="weui-media-box__title"><span  class="title" style="color: #888888;float: right;"></span></h4>
                    </div>
                </a>
            </div>
        </div>
</div>

    <div class="weui-cells__title"></div>
    <div class="weui-cells">
        <a class="weui-cell  weui-cell_access" href="javascript:">
            <div class="weui-cell__bd">
                <p>配送快递</p>
            </div>
            <div class="weui-cell__ft" ><span  class="shippingName" style="color: red"></span></div>
        </a>
        <a class="weui-cell  weui-cell_access" href="javascript:">
            <div class="weui-cell__bd">
                <p>运费</p>
            </div>
            <div class="weui-cell__ft" ><span  class="postFee" style="color: red"></span></div>
        </a>

        <a class="weui-cell  weui-cell_access" href="javascript:">
            <div class="weui-cell__bd">
                <p>积分</p>
            </div>
            <div class="weui-cell__ft" ><span  class="jifen" style="color: red"></span></div>
        </a>
        <a class="weui-cell  weui-cell_access" href="javascript:">
            <div class="weui-cell__bd">
                <p>优惠券</p>
            </div>
            <div class="weui-cell__ft" ><span  class="youhui" style="color: red"></span></div>
        </a>

    </div>

    <div class="container">
        <div class="page__bd" style="height: 100%;">
            <div class="weui-tab">
                <div class="weui-tab__panel">

                </div>
                <div class="weui-tabbar">
                    <div class="weui-tabbar__item">
                        <p class="weui-tabbar__label" style="font-size: 20px">总价格<span class="zhongjia" style="color: red;"></span></p>
                    </div>
                    <div class="weui-tabbar__item">
                        <a href="javascript:" class="weui-btn weui-btn_primary" onclick="jiesuan()">结算</a>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript">

        /*$(function () {
            let orderId = localStorage.getItem("orderId");
            $.ajax({
                type:'get',
                url:'http://localhost:9502/tb-stock/getorderid',
                data:{orderId:orderId},
                success: function (data) {
                    console.log(data)
                    if(data==1){
                        alert("排队中")
                    }else if(data==2){
                        return;
                    }
                }
            })
        })*/

        $(function () {
            var id= location.search.replace(/[^\d]/g, "");
            var token=localStorage.getItem('token')
            $.ajax({
                type:'get',
                url:'http://localhost:9503/order/listorder',
                data:{skuId:id,token:token},
                success: function (data) {
                    $(".postFee").append(data.postFee);
                    $(".shippingName").append(data.shippingName);
                    $(".jifen").append(data.jifen);
                    $(".youhui").append(data.youhui);
                    $(".seckillPrice").append(data.seckillPrice);
                    $(".title").append(data.title);
                    $(".actualPay").append(data.actualPay);
                    $(".zhongjia").append(data.zhongjia);
                    console.log(data)
                    console.log(token)
                    /*console.log(zhongjia)*/
                }
            })
        })


    </script>
</div>
</body>
</html>
<script type="text/javascript">
    function jiesuan(){
        var token=localStorage.getItem('token')
        var oid=localStorage.getItem('orderId');
        var pid=location.search.replace(/[^\d]/g, "");
        var zj=$(".zhongjia").text();
        var actualPay=$(".actualPay").text();
        var postFee=$(".postFee").text();
        var shippingName=$(".shippingName").text();
        console.log(zj);
         $.ajax({
              type:'post',
              url:'http://localhost:9503/pay/addOrder',
              data:{
                  totalPay:zj,
                  actualPay:actualPay,
                  paymentType:true,
                  postFee:postFee,
                  shippingName:shippingName,
                  uid:token,
                  skuId:pid,
                  orderId:oid
              },dataType:'json',
              success:function (data){
                  console.log(data);
                  window.location.href='pay.html';
              }
         })
    }
</script>